<%-- 自定义实体添加页面 --%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/views/common/taglibs.jsp" %>

<!DOCTYPE>
<html>
<head>
    <!-- 引入通用js、css文件(xiaogq) -->
    <meta name="decorator" content="bootstrap"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/css/system/custom/entity/entity_add.css"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/css/common/operation/sys_operation.css"/>
</head>
<body>
<!-- 加载列表操作 -->
<div class="button_list">
    <a href="javascript:;" onclick="saveEmployee()">
            <span class="span_button">
                <span><img src="${ctx}/image/common/operation/oper_SAVE.png"></span>
                <span name="buTitle">保存</span>
            </span>
    </a>
    <a href="javascript:;" onclick="javascript:parent.closeTab();">
            <span class="span_button">
                <span><img src="${ctx}/image/common/operation/oper_CANCEL.png"></span>
                <span name="buTitle">取消</span>
            </span>
    </a>
</div>

<div class="content row">
    <h3>基础信息</h3>
    <hr>
    <jsp:include page="/views/system/organization/form/emp_form_add.jsp" flush="true" />
</div>

<script type="text/javascript">
    function validateMethod(){
        var flag = true;
        <c:forEach items="${fieldRecords}" var="records">
            if(${records.fieldRecord.nulldisable == true}){
                var r = $("#${records.fieldRecord.name}").val();
                if(r == ""){
                    alert("${records.fieldRecord.inchinese}不能为空!");
                    flag = false;
                    $("#${records.fieldRecord.name}").focus();
                    return flag;
                }
            }
        </c:forEach>
        return flag;
    }

    //員工信息保存方法(xiaogq)
    function saveEmployee(){
        $('#entity_form').ajaxForm({
            beforeSubmit:validateMethod,
            success:function(balkJson) {
                balkJson = eval("(" + unescape(balkJson) + ")");
                if(balkJson.error){
                    alert(balkJson.error);
                    return;
                }
                parent.closeTab(1);
            }
        });
        $("#entity_form").submit();
    }
</script>
</body>
</html>
